package prickworlds.gui;

import prickworlds.graphics.Font;
import prickworlds.structure.Drawable;
import prickworlds.structure.EventHandler;

/**
 * Base class for every control
 * 
 * @author Faruk Acibal, Richard Dziambor, Christian Holzreuter, Nicolas Winkler
 * 
 */
public abstract class Control implements Drawable, EventHandler {

	/**
	 * the x-coordinate of the upper left corner of the control
	 */
	protected int x;

	/**
	 * the y-coordinate of the upper left corner of the control
	 */
	protected int y;

	/**
	 * the width of the control
	 */
	protected int width;

	/**
	 * the height of the control
	 */
	protected int height;

	/**
	 * if the control is currently being displayed
	 */
	protected boolean visible;

	/**
	 * 
	 */
	static protected Font font;

	/**
	 * default constructor
	 */
	protected Control() {
		setVisible(true);
	}

	/**
	 * creates a {@link Control} from the specified arguments
	 * 
	 * @param x
	 *            the x-coordinate of the upper left corner of the control
	 * @param y
	 *            the y-coordinate of the upper left corner of the control
	 * @param width
	 *            the width of the control
	 * @param height
	 *            the height of the control
	 */
	protected Control(int x, int y, int width, int height) {
		this();
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}

	/**
	 * returns the current {@link Font}
	 * 
	 * @return the {@link Font} that is used by the Controls
	 */
	public static Font getFont() {
		return font;
	}

	/**
	 * sets the {@link Font} for the Controls
	 * 
	 * @param font
	 *            the new {@link Font}
	 */
	public static void setFont(Font font) {
		Control.font = font;
	}

	public void setVisible(boolean b) {
		this.visible = b;
	}

	public boolean isVisible() {
		return visible;
	}
}
